Skip to content

Only display the input fields that are configured in the scope #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 19, 2025

Conversation

AdamGrzybkowski
Copy link
Contributor

Description

This PR allows displaying only certain AboutInputFields in the editors per the scope config.

The public API was already done. The changes made are:

  • Introduce the option to pick specific fields within the Demo App.
  • Pass the aboutFields from the scope config to the AboutEditorViewModel and set the visibility in the state.
  • Adjust the UI component to respect the visibility flags.
aboutFields.mp4

Testing Steps

  1. Launch the demo app
  2. Select the About or AvatarAndAbout scope
  3. Tap on the About fields
  4. Select the ones you want
  5. Close the sheet
  6. Open the QE
  7. Verify the selected fields are visible

@AdamGrzybkowski AdamGrzybkowski added the [Feature] Gravatar-Quickeditor Gravatar Quick Editor module label May 16, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a configuration option that restricts the display of About input fields in the editors by passing a set of visible fields down through the view model and UI components. Key changes include:

  • Replacing usages of AboutInputField with AboutEditorField in the editor components and tests.
  • Updating the view model and profile mapping to respect the configured visibility flags.
  • Adding a new about fields picker in the demo app to allow dynamic field configuration.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
AboutEditorViewModelTest.kt Updated tests to use the new visibility configuration and field type.
AboutEditorTest.kt Modified tests to verify the UI state correctly reflects visible fields.
QuickEditorScopeOption.kt Added a getter to expose aboutFields based on the scope configuration.
ProfessionalSection.kt, PersonalSection.kt, AboutSection.kt Wrapped field rendering with conditional visibility checks and updated field types.
AboutFields.kt Modified data classes and update functions to use AboutEditorField with a new visible flag.
AboutEditorViewModel.kt Changed the view model to map the profile using configured visible fields and updated API types.
AboutEditorEvent.kt, AboutEditor.kt Adjusted event and editor definitions to use AboutEditorField.
AboutFieldsBottomSheet.kt Adapted the bottom sheet component to work with the field configuration.
AvatarUpdateTab.kt Integrated an about fields picker and updated scope configuration to use the chosen fields.
demo-app/build.gradle.kts Added a dependency on composable core components.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 16, 2025

📲 You can test the changes from this Pull Request in Gravatar Demo by scanning the QR code below to install the corresponding build.
App NameGravatar Demo
Commit4179c74
Direct Downloadgravatar-demo-prototype-build-pr631-4179c74.apk

@AdamGrzybkowski AdamGrzybkowski marked this pull request as draft May 16, 2025 08:28
@AdamGrzybkowski AdamGrzybkowski marked this pull request as ready for review May 16, 2025 08:29
@AdamGrzybkowski AdamGrzybkowski marked this pull request as draft May 16, 2025 10:31
@AdamGrzybkowski
Copy link
Contributor Author

@etoledom I've marked this as a Draft. I'm not 100% happy with how the state is modeled in the AboutEditorViewModel and I want to change that.

@AdamGrzybkowski AdamGrzybkowski marked this pull request as ready for review May 16, 2025 11:49
@AdamGrzybkowski
Copy link
Contributor Author

AdamGrzybkowski commented May 16, 2025

@etoledom This is now ready to review. I did modify the model for the AboutEditor state in 94bcfd7. Mainly, I've decided to keep about fields as a Set rather than having them all defined with a visibility flag set. Now we simply hold only those that should be visible. This significantly reduced the complexity of the UI components and even reduced the number of them as they are now more generic.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for displaying only configured About input fields in the editor based on scope settings.

  • Passes aboutFields from scope config into AboutEditorViewModel to control visibility.
  • Refactors state and UI to use AboutEditorField sets instead of fixed AboutFields classes.
  • Introduces a bottom sheet in the demo app for selecting visible About input fields.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AboutEditorViewModelTest.kt Updated tests to use new AboutEditorField API
AboutEditorViewModel.kt Accepts visibleAboutFields and maps profile fields accordingly
AboutSection.kt Refactored UI to render dynamic field sets
AboutInputField.kt Added ordering and category helpers for fields
AboutFieldsBottomSheet.kt New UI for picking visible About fields in demo app
AvatarUpdateTab.kt Integrated bottom sheet and bound selected fields in demo app
Comments suppressed due to low confidence (3)

gravatar-quickeditor/src/test/java/com/gravatar/quickeditor/ui/abouteditor/AboutEditorViewModelTest.kt:258

  • You’ve added a test for personal-only visibility—consider adding a complementary test for the professional-only case to ensure that section toggling works as expected.
fun `given only personal about section visible when profile fetched then uiState is updated`() = runTest {

demo-app/src/main/java/com/gravatar/demoapp/ui/components/AboutFieldsBottomSheet.kt:44

  • [nitpick] The parameter name aboutFields in this sheet conflicts with the editor’s aboutFields type (AboutEditorField). Consider renaming to selectedFields or similar for clarity.
internal fun AboutFieldsBottomSheet( aboutFields: Set<AboutInputField>,

gravatar-quickeditor/src/test/java/com/gravatar/quickeditor/ui/abouteditor/AboutEditorViewModelTest.kt:8

  • Tests reference AboutEditorField, but there's no import; add import com.gravatar.quickeditor.ui.abouteditor.AboutEditorField to avoid compilation errors.
import com.gravatar.quickeditor.ui.editor.AboutInputField

Base automatically changed from adam/GRA-81_2 to feature/quick_editor_about_info May 16, 2025 13:44
There's a crash caused by rememberSaveable { mutableStateOf(AboutInputField.all) }
The default saver doesn't support non-primitive types.
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great 🎉

One small detail comparing with Figma:
It seems that when there's only one section present, the section title is not being shown:

Figma Implemented
CleanShot 2025-05-19 at 08 27 08@2x CleanShot 2025-05-19 at 08 40 10@2x

This is how it was implemented on iOS also.

If there are fields from only one section, there's no section title. But when there are at least 1 field from each section, the section titles are being shown.

Same section Different sections
CleanShot 2025-05-19 at 08 45 53@2x CleanShot 2025-05-19 at 08 46 06@2x

@AdamGrzybkowski
Copy link
Contributor Author

Ohh I missed that detail, thanks.

@AdamGrzybkowski
Copy link
Contributor Author

@etoledom Fixed!

@AdamGrzybkowski AdamGrzybkowski requested a review from etoledom May 19, 2025 08:04
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Thank you for the update 🙏

@AdamGrzybkowski AdamGrzybkowski merged commit a461f4d into feature/quick_editor_about_info May 19, 2025
14 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the adam/GRA-33 branch May 19, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Gravatar-Quickeditor Gravatar Quick Editor module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants